package com.cxka.payment.controller;

import com.cxka.common.result.IResult;
import com.cxka.payment.domain.dto.CreateOrderDTO;
import com.cxka.payment.service.PaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cxka-pay")
@Api(value = "创建订单demo", tags = "创建订单demo")
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    /**
     * 创建订单
     *
     * @return
     */
    @PostMapping("/create-order")
    @ApiOperation("创建订单")
    public IResult<Boolean> createOrder(@RequestBody @Validated(CreateOrderDTO.Insert.class) CreateOrderDTO dto) {

        boolean flag = paymentService.createOrder(dto);

        return IResult.success(flag);
    }
}
